<?php

/**
 *
 */
class buildallTask extends sfBaseTask
{
  protected function configure()
  {
    // // add your own arguments here
    // $this->addArguments(array(
    //   new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED, 'My argument'),
    // ));

    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
      // add your own options here
    ));

    $this->namespace        = 'u';
    $this->name             = 'build-all';
    $this->briefDescription = '';
    $this->detailedDescription = <<<EOF
The [build-all|INFO] task does things.
Call it with:

  [php symfony u:build-all|INFO]
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();

    sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true));
    
    // add your code here
    set_time_limit(0);
    
    echo "===== build-schema =====\r\n";
    echo exec('symfony propel:build-schema');  
    
    echo "\r\n\r\n===== fix-schema =====\r\n";
    echo exec('symfony u:fix-schema'); 

    echo "\r\n\r\n===== build-model =====\r\n";
    echo exec('symfony propel:build-model'); 

    echo "\r\n\r\n===== build-form =====\r\n";
    echo exec('symfony propel:build-form'); 

    echo "\r\n\r\n===== build-filter =====\r\n";
    echo exec('symfony propel:build-filter'); 
           
    echo "\r\n\r\nDone\r\n";
    
  }
  
  
    
}
